package cn.itbaizhan.service;


import cn.itbaizhan.bean.UserReceiveAddress;
import org.nutz.dao.Cnd;
import org.nutz.ioc.loader.annotation.IocBean;

import java.util.List;

@IocBean(name = "userReceiveAddressService", fields = {"dao"})
public class UserReceiveAddressService extends BaseService {

    /**
     * 添加地址
     *
     * @param order
     * @return
     */
    public UserReceiveAddress addAddress(UserReceiveAddress order) {
        return dao.insert(order);
    }

    /**
     * 用户地址列表
     *
     * @return
     */
    public List<UserReceiveAddress> getAddressList(int id) {
        return dao.query(UserReceiveAddress.class, Cnd.wrap("user_id=" + id + " order by id desc"), null);
    }

    /**
     * 修改
     *
     * @param order
     * @return
     */
    public int editAddress(UserReceiveAddress order) {
        return dao.update(order);
    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    public int deleteAddress(int id) {
        return dao.delete(UserReceiveAddress.class, id);
    }
}
